package com.ruoyi.activiti.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.activiti.mapper.DanWorkflowLeaveMapper;
import com.ruoyi.activiti.domain.DanWorkflowLeave;
import com.ruoyi.activiti.service.IDanWorkflowLeaveService;

/**
 * 请假Service业务层处理
 *
 * @author cjie
 * @date 2022-12-20
 */
@Service
public class DanWorkflowLeaveServiceImpl implements IDanWorkflowLeaveService {
    @Autowired
    private DanWorkflowLeaveMapper danWorkflowLeaveMapper;

    /**
     * 查询请假
     *
     * @param id 请假ID
     * @return 请假
     */
    @Override
    public DanWorkflowLeave selectDanWorkflowLeaveById(String id) {
        return danWorkflowLeaveMapper.selectDanWorkflowLeaveById(id);
    }

    /**
     * 查询请假列表
     *
     * @param danWorkflowLeave 请假
     * @return 请假
     */
    @Override
    public List<DanWorkflowLeave> selectDanWorkflowLeaveList(DanWorkflowLeave danWorkflowLeave) {
        return danWorkflowLeaveMapper.selectDanWorkflowLeaveList(danWorkflowLeave);
    }

    /**
     * 新增请假
     *
     * @param danWorkflowLeave 请假
     * @return 结果
     */
    @Override
    public int insertDanWorkflowLeave(DanWorkflowLeave danWorkflowLeave) {
        danWorkflowLeave.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        danWorkflowLeave.setCreateTime(DateUtils.getNowDate());
        danWorkflowLeave.setCreateBy(SecurityUtils.getUsername());
        return danWorkflowLeaveMapper.insertDanWorkflowLeave(danWorkflowLeave);
    }

    /**
     * 修改请假
     *
     * @param danWorkflowLeave 请假
     * @return 结果
     */
    @Override
    public int updateDanWorkflowLeave(DanWorkflowLeave danWorkflowLeave) {
        danWorkflowLeave.setUpdateTime(DateUtils.getNowDate());
        danWorkflowLeave.setUpdateBy(SecurityUtils.getUsername());
        return danWorkflowLeaveMapper.updateDanWorkflowLeave(danWorkflowLeave);
    }

    /**
     * 批量删除请假
     *
     * @param ids 需要删除的请假ID
     * @return 结果
     */
    @Override
    public int deleteDanWorkflowLeaveByIds(String[] ids) {
        return danWorkflowLeaveMapper.deleteDanWorkflowLeaveByIds(ids);
    }

    /**
     * 删除请假信息
     *
     * @param id 请假ID
     * @return 结果
     */
    @Override
    public int deleteDanWorkflowLeaveById(String id) {
        return danWorkflowLeaveMapper.deleteDanWorkflowLeaveById(id);
    }
}
